import { constantRoutes, asyncRoutes } from '@/router'
const state = {
  routes: []
}

const mutations = {
  setRouter(state, data) {
    state.routes = [...constantRoutes, ...data]
  }

}

const actions = {
  filterRouter(store, data) {
    const newAsyncRoutes = asyncRoutes.filter(item => data.includes(item.name))
    console.log(newAsyncRoutes)
    store.commit('setRouter', newAsyncRoutes)
    return newAsyncRoutes
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
